package com.jquest.editor.components;

import com.jquest.data.Map;
import com.l2fprod.common.propertysheet.DefaultProperty;
import com.l2fprod.common.propertysheet.PropertySheetTable;
import com.l2fprod.common.propertysheet.PropertySheetTableModel;

import java.util.ArrayList;

/**
 * Created by IntelliJ IDEA.
 * User: Johan
 * Date: 2009-dec-19
 * Time: 13:48:15
 * To change this template use File | Settings | File Templates.
 */
public class PropertyGenerator {

    public static PropertySheetTableModel getProperty(Object object, PropertySheetTableModel psm) {

        //ToDo: Ugly way, but it works, needs to be completed for all entities used on the map
        if(object instanceof Map) {
            Map map = (Map) object;

            psm.addProperty(generate("Name", "Sample Map", "Common", "Name of the map", true));
            psm.addProperty(generate("Height", map.getHeight(), "Common", "Height in tile-size", false));
            psm.addProperty(generate("Width", map.getWidth(), "Common", "Width in tile-size", false));
        }
        return psm;
    }

    private static DefaultProperty generate(String name, Object value, String category, String description, boolean editable) {
        DefaultProperty prop = new DefaultProperty();
        prop.setCategory(category);
        prop.setDisplayName(name);
        prop.setShortDescription(description);
        prop.setValue(value);
        prop.setEditable(editable);
        return prop;
    }

}
